Package com.fsf.news.actor.websocket
Class NewsUserActorTest
java.lang.Object
com.fsf.news.actor.websocket.NewsUserActorTest
@ExtendWith({org.mockito.junit.jupiter.MockitoExtension.class,org.apache.pekko.actor.testkit.typed.javadsl.TestKitJUnit5Extension.class})
class NewsUserActorTest
extends Object
Unit tests for the NewsUserActor class.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) com.fsf.news.actor.websocket.factory.NewsWorkerActorFactory(package private) com.fasterxml.jackson.databind.JsonNode(package private) com.fasterxml.jackson.databind.ObjectMapper(package private) org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidTests that sending a Close message terminates the user actor session.(package private) voidConfirms proper termination of the user actor along with a stopped worker.(package private) voidTests that a Create message triggers creation of a worker session via the factory.(package private) voidTests that a WebSocket flow forwards messages to the corresponding worker.(package private) voidTests that multiple duplicate Create messages use the same WebSocket flow.(package private) voidTests supervision of a worker actor, ensuring it restarts after failure.(package private) voidConfirms that retries stop after reaching the configured limit.
-
Field Details
-
testKit
@JUnit5TestKit org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit testKit -
factory
@Mock com.fsf.news.actor.websocket.factory.NewsWorkerActorFactory factory -
objectMapper
@Mock com.fasterxml.jackson.databind.ObjectMapper objectMapper -
node
@Mock com.fasterxml.jackson.databind.JsonNode node
-
-
Constructor Details
-
NewsUserActorTest
NewsUserActorTest()
-
-
Method Details
-
testCreateMessage
@Test void testCreateMessage()Tests that a Create message triggers creation of a worker session via the factory. -
testCloseMessage
@Test void testCloseMessage()Tests that sending a Close message terminates the user actor session. -
testCloseMessageWithWorker
@Test void testCloseMessageWithWorker()Confirms proper termination of the user actor along with a stopped worker. -
testCreateMessageMultipleDuplicateUserSesssions
@Test void testCreateMessageMultipleDuplicateUserSesssions()Tests that multiple duplicate Create messages use the same WebSocket flow. -
testCreateMessageFlowToWorker
@Test void testCreateMessageFlowToWorker() throws com.fasterxml.jackson.core.JsonProcessingExceptionTests that a WebSocket flow forwards messages to the corresponding worker.- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if JSON parsing fails during testing
-
testCreateMessageSupervision
@Test void testCreateMessageSupervision()Tests supervision of a worker actor, ensuring it restarts after failure. -
testCreateMessageSupervisionRetryLimit
@Test void testCreateMessageSupervisionRetryLimit()Confirms that retries stop after reaching the configured limit.
-